package tutorial.java.swing;

import javax.swing.JFrame;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JTextArea;

public class PopupMenu {
	public static void main(String[] args){
		JFrame frame = new JFrame("Popup Menu");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		JPopupMenu popup = new JPopupMenu("Option");
		JMenuItem miCopy = new JMenuItem("Copy");
		JMenuItem miPaste = new JMenuItem("Paste");
		JMenuItem miDelete = new JMenuItem("Delete");
		
		popup.add(miCopy);
		popup.add(miPaste);
		popup.addSeparator();
		popup.add(miDelete);
		
		JTextArea text = new JTextArea();
		text.setComponentPopupMenu(popup);
		
		frame.add(text);
		frame.setSize(500, 400);
		frame.setVisible(true);
		frame.setResizable(false);
		frame.setLocationRelativeTo(null);
	}
}
